package com.zq.vaccinum.domain;

import com.zq.vaccinum.constant.Constants;

/**
 * 统一响应格式
 * @Author: zq
 * @Date: 2023/08/04/2:03
 * @Description:
 */
public class R {

    public static final int SUCCESS = Constants.SUCCESS;

    public static final int FAIL = Constants.ERROR;

    private int code;

    private String msg;

    private Object data;

    public R() {
    }

    public R(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static R ok(){
        return new R(SUCCESS,"操作成功",null);
    }
    public static R ok(Object data){
        return new R(SUCCESS,"操作成功",data);
    }
    public static R fail(){
        return new R(FAIL,"操作失败",null);
    }
    public static R fail(Object data){
        return new R(FAIL,"操作失败",null);
    }
    public static R fail(String msg){
        return new R(FAIL,msg,null);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
